package com.example.searchcenter.center;


import com.example.searchcenter.R;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

/***
 * 
 * @author NguyenTrung
 * Function: view albums of places as single Gridview
 */
public class AlbumsFragment extends Fragment {
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View rootView = inflater.inflate(R.layout.fragment_albums, container, false);
		GridView gridView = (GridView) rootView.findViewById(R.id.grid_view);
		// Instance of ImageAdapter Class
        gridView.setAdapter(new ImageAdapter(getActivity()));
        
        /**
         * On Click event for Single Gridview Item
         * */
        gridView.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v,
                    int position, long id) {
 
                // Sending image id to FullScreenActivity
                Intent i = new Intent(getActivity(), FullImageActivity.class);
                // passing array index
                i.putExtra("id", position);
                startActivity(i);
            }
        });
		return rootView;
	}

}
